#include "String.h"

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

STRING::STRING() : length(0), buffer(nullptr) {}

STRING::STRING(const char* str) : length(strlen(str)), buffer(new char[strlen(str)]) {
    for (int i = 0; i < length; i++) buffer[i] = str[i];
}

STRING::STRING(const STRING& other) : length(other.length), buffer(new char[other.length]) {
    for (int i = 0; i < length; i++) buffer[i] = other.buffer[i];
}

// STRING& STRING::operator=(const STRING& other) {
//     if (this == &other) return *this;
//     delete[] buffer;
//     length = other.length;
//     for (int i = 0; i < length; i++) buffer[i] = other.buffer[i];
//     return *this;
// }

STRING::~STRING() {
    delete[] buffer;
}